8  Making References

Another part of Open Science is making sure that you give credit where credit is due. You should incorporate references as appropriate into your reports. There are two key things that you’ll need for including references: a citation style and a bibliography file.

8.1 Citation Style

By default, Quarto will use Chicago citation style but you can change this with the YAML key csl. The value you provide to this key is the file name of the Citation Style Language file that is in the same folder as your Quarto document. For this Quarto guide, I used csl: apa7.csl and I have the apa7.csl file with my QMD file.

Tip

You can find CSL files for the American Psychological Association’s 7th Ed. (apa7.csl) and the Modern Language Association’s 9th Edition (MLA9.csl) in the Course Project Guidelines Template Repo.

Alternatively, you can also trigger a download of your desired citation style’s CSL file by entering the URL for the style. For example, entering https://www.zotero.org/styles/apa will trigger a download of the most current APA CSL file. You can browse a full list at https://www.zotero.org/styles/.

8.2 Bibliography File

The bibliography file is something that you can create via another application (e.g., BibTeX, EndNote, Mendaly, Zotero) or you can use the built-in tools of RStudio Desktop.

I’m a supporter of Zotero as a reference manager. If you download and install Zotero for your computer, RStudio should automatically detect Zotero and connect with it. To learn more about using Zotero, I recommend the PSU Libraries Zotero Guide (Amsberry, n.d.).

One nice thing about using RStudio’s tools (especially with Zotero) is that this will build the bibliography file for you as you add references to your Quarto document. The auto-generated bibliography file will show up as references.bib and appear in the same folder/directory as your QMD file. In your YAML header, you’ll want to make sure that you have the key: value pair bibliography: references.bib. If your bibliography file is named something else, just change the value to match the file name. (The file extension should still be bib.)

8.2.1 Using Zoterobib

If you don’t want to use a full reference manager yet (you really should), you can build a bib file on an ad hoc basis. The website zoterobib let’s you add references one at a time to the page. You can look up different sources via URL, DOI, or some other identifier. Additionally, you can manually add a reference as well as edit any existing reference.

As long as you are using the same browser tab/session, you can keep adding references to the list. When you’re done, you can click the down arrow on the right-hand side of the Copy to Clipboard button and select the Download BibTeX option. This will generate a citations.bib file for you to download and save to your computer. You can then move that file into your project. Once that file is present and linked in the YAML header, you’ll be able to insert your citations.

8.3 Adding References to Your Document

RStudio’s Citation tool is generally only available in the Visual editor mode. However, once you get the hang of the citations, you can start including them in the Source editor mode. Keep in mind that there are generally two ways to have a citation in the body of your report: as a parenthetical and as an in-text citation. The parenthetical will depend upon your citation style and could appear as the name(s) of the author(s) followed by the date both inside a set of parentheses or as a bracketed number. The in-text citation generally lists the author’s last name followed by just the date in parentheses. Here’s an example of the two citation styles.

  • Parenthetical: Check out libraries Zotero guide (Amsberry, n.d.).
    • Text in Quarto File: Check out libraries Zotero guide [@amsberry].
  • In-text: Amsberry (n.d.) created a useful guide for Zotero.
    • Text in Quarto File: @amsberry created a useful guide for Zotero.

The key to adding a reference to your narrative text is to use the at-sign, @, followed by the citation’s id, just like a cross-reference. Enclosing the cross-reference in square brackets will use the parenthetical style, otherwise you’ll get in-text style.

Caution

Be careful when switching back-and-forth between the Source and Visual editor views in RStudio Desktop. Because the Visual editor attempts to render certain elements (e.g., mathematics, divisions surrounded by triple-colons–:::), you might find that some of your code appear “hashed” or altered.

8.4 Citing Data Sets

Yes, you must cite data sets. No, just mentioning where you got the data (e.g., the NBA or ESPN) is not sufficient. You need to build a proper reference for each data set that you use.

Here are some tools to help you:

  • APA Data Set References: contains an example and the required elements for citing a data set.
  • Zoterobib: The manual entry tool has a “Dataset” item type option that will give you all of the fields that you might want for building a reference.

8.5 The References Section

The last piece for working with references in your reports is to add a Reference Sections (a.k.a. Works Cited or Bibliography). This generally goes at the end of your document and before any appendices. Quarto will automatically build this portion of your document for you if you have used citations.

To control the location of the references section you’ll want to include the following code (Listing 8.1) in your Quarto document.

Listing 8.1: Quarto Commands for Making a Reference Section
 \{\{< pagebreak >\}\}  
 # References  

 ::: {#refs}
 :::

In the first line of Listing 8.1 will give you a command that will put a page break into your rendered document before starting the references section. You can change the text in the second line from “References” to “Works Cited”, “Bibliography”, or whatever term is appropriate for your chosen writing/citation style. The third and fourth lines should appear as they do in Listing 8.1.

CautionRemove the Backslashes

In Listing 8.1, you’ll notice that there are four backslashes (i.e., \) that appear in the first line (with pagebreak). You will need to remove these backslashes when you copy this code into your document. They appear here so that you can see this line of code.